package cn.itcast.xuesheng.web.converter;

import org.springframework.core.convert.converter.Converter;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class StringtoDateConverter implements Converter<String, Date> {

    @Override
    public Date convert(String source) {
        DateFormat dt=new SimpleDateFormat("yyyy-mm-dd");
        try {
            return dt.parse(source);
        } catch (ParseException e) {
            throw new RuntimeException("Converter出错了");
        }
    }
}
